home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / xmasspak / vector / vector8.asm < prev    next >
Encoding:
Assembly Source File  |  1995-12-12  |  22.1 KB  |  1,099 lines

  1. ;
  2. ;  Line-Vector-routine v2.2
  3. ;
  4. ;  done 1995 by Capella/Escape
  5. ;  this routine is only for Escape-usage .... DON'T SPREAD!!!!
  6. ;
  7.  
  8. ideal
  9. model large
  10. p386n
  11. stack 256
  12.  
  13. assume cs:coding
  14.  
  15. points = 6                ; Anzahl Punkte
  16. areas = 6               ; Anzahl Linien
  17. frames = 2              ; Anzahl Flächen 
  18. ;-------------------------------------
  19. macro  setcol   backcol
  20.  
  21.        mov dx,03c8h
  22.        xor al,al
  23.        out dx,al
  24.        inc dx
  25.        mov al,backcol
  26.        out dx,al
  27.        out dx,al
  28.        out dx,al
  29.  
  30. endm
  31. ;-------------------------------
  32. macro  setpage newpage
  33.  
  34.        mov dx,03d4h
  35.        mov ax,newpage
  36.        out dx,ax
  37.  
  38. endm
  39. ;-------------------------------
  40.  
  41. segment  coding
  42.  
  43. start:     mov ax,data1
  44.            mov ds,ax
  45.            assume ds:data1
  46.  
  47.            mov ax,0a000h
  48.            mov es,ax
  49.            assume es:0a000h
  50.  
  51.            call set320400
  52.           ;  call set640400
  53.  
  54.            mov ax,0a800h
  55.            mov es,ax
  56.            assume es:0a800h
  57.            
  58. main:      call  rotate_x       
  59.            call  rotate_y
  60.            call  rotate_z
  61.            
  62.           
  63.  
  64.            call transform
  65.            
  66.            
  67.  
  68.            mov [ds:color],1         ; Objekt auf Seite 2 darstellen
  69.            mov di,offset _2dpoints
  70.            call draw_obj
  71.            call fill_obj
  72.            
  73.            
  74.  
  75.            setpage 800ch           ; Seite 2 an
  76.            
  77.            mov dx,03dah
  78. wb1:       in al,dx
  79.            test al,8
  80.            jne wb1
  81. wb2:       in al,dx
  82.            test al,8
  83.            je wb2
  84.  
  85.            mov ax,0a000h
  86.            mov es,ax
  87.            assume es:0a000h
  88.            
  89.            mov dx,03c4h
  90.            mov ax,0f02h
  91.            out dx,ax
  92.  
  93.            mov cx,32000/4        ; Objekt auf Seite 1 löschen
  94.            xor si,si
  95.            xor eax,eax
  96. del_p1:    mov [es:si],eax
  97.            add si,4
  98.            dec cx
  99.            jnz del_p1
  100.            
  101.            
  102.  
  103.            call get_oldpos         ; Positionen von Seite 2 retten
  104.            
  105.            
  106.           
  107.           ;add [ds:xw],2
  108.           ; add [ds:yw],2
  109.           ; add [ds:zw],2
  110.            
  111.            call rotate_x        
  112.            call rotate_y
  113.            call rotate_z
  114.            
  115.            call transform
  116.            
  117.            mov [ds:color],1        ; Objekt auf Seite 1 darstellen
  118.            mov di,offset _2dpoints
  119.            call draw_obj
  120.            call fill_obj
  121.            
  122.            setpage 000ch           ; Seite 1 an
  123.        
  124.            mov dx,03dah
  125. wb3:       in al,dx
  126.            
  127.            test al,8
  128.            jne wb3
  129. wb4:       in al,dx
  130.            test al,8
  131.            je wb4
  132.  
  133.            mov ax,0a800h
  134.            mov es,ax
  135.            assume es:0a800h
  136.            
  137.            mov dx,03c4h
  138.            mov ax,0f02h
  139.            out dx,ax
  140.  
  141.            mov cx,32000/4
  142.            xor si,si
  143.            xor eax,eax
  144. del_p2:    mov [es:si],eax
  145.            add si,4
  146.            dec cx
  147.            jnz del_p2
  148.            
  149.            call get_oldpos         ; Positionen von Seite 1 retten
  150.            
  151.            add [ds:xw],2        ; Neue Winkel berechnen
  152.            add [ds:yw],0
  153.            add [ds:zw],2
  154.            
  155. warte:     in al,60h            ; Auf 'ESCAPE'-Taste warten
  156.            cmp al,01
  157.            jne main
  158.  
  159.            
  160. exit:      mov ax,0003h
  161.            int 10h
  162.            mov ax,4c00h
  163.            int 21h
  164.  
  165. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  166. ; ROTATIONS-ROUTINE / dreht die 3d-koordinaten in x,y und z-richtung
  167. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  168.  
  169. proc  rotate_x    NEAR
  170.      
  171.      mov   si,offset xpos
  172.      mov   di,offset _3dpoints
  173.      mov   cx,points
  174.  
  175. rotx_it:
  176.      push  cx
  177.      
  178.      mov   ax,[ds:zw]       
  179.      call  cosinus
  180.      imul  [word ds:si]
  181.      mov   cx,dx
  182.      mov   ax,[ds:zw] 
  183.      call  sinus
  184.      imul  [word ds:si+2*points]
  185.      sub   dx,cx
  186.      sal   dx,1
  187.      sal   dx,1
  188.      mov   [ds:di],dx  
  189.  
  190.      mov   ax,[ds:zw]       
  191.      call  sinus
  192.      imul  [word ds:si]
  193.      mov   cx,dx
  194.      mov   ax,[ds:zw] 
  195.      call  cosinus
  196.      imul  [word ds:si+2*points]
  197.      add   dx,cx
  198.      sal   dx,1
  199.      sal   dx,1
  200.      mov   [ds:di+2*points],dx                
  201.       
  202.      pop cx
  203.      add si,2
  204.      add di,2
  205.      dec cx
  206.      jnz rotx_it
  207.      ret
  208.  
  209. endp  rotate_x
  210.  
  211. proc  rotate_y    NEAR
  212.  
  213.      mov cx,points
  214.      mov si,offset xpos
  215.      mov di,offset _3dpoints
  216.  
  217. roty_it:     
  218.      push cx
  219.  
  220.      mov   ax,[ds:yw]       
  221.      call  cosinus
  222.      imul  [word ds:si]
  223.      mov   cx,dx
  224.      mov   ax,[ds:yw] 
  225.      call  sinus
  226.      imul  [word ds:si+4*points]
  227.      sub   dx,cx
  228.      sal   dx,1
  229.      sal   dx,1
  230.      mov   [ds:di],dx  
  231.  
  232.      mov   ax,[ds:yw]       
  233.      call  sinus
  234.      imul  [word ds:si]
  235.      mov   cx,dx
  236.      mov   ax,[ds:yw] 
  237.      call  cosinus
  238.      imul  [word ds:si+4*points]
  239.      add   dx,cx
  240.      sal   dx,1
  241.      sal   dx,1
  242.      mov   [ds:di+4*points],dx                
  243.       
  244.      pop cx
  245.      add si,2
  246.      add di,2
  247.      dec cx
  248.      jnz roty_it
  249.      ret
  250.  
  251. endp  rotate_y
  252.  
  253. proc  rotate_z    NEAR
  254.  
  255.      mov cx,points
  256.      mov si,offset xpos
  257.      mov di,offset _3dpoints
  258.  
  259. rotz_it:
  260.      
  261.      push cx
  262.  
  263.      mov   ax,[ds:xw]       
  264.      call  cosinus
  265.      imul  [word ds:si+2*points]
  266.      mov   cx,dx
  267.      mov   ax,[ds:xw] 
  268.      call  sinus
  269.      imul  [word ds:si+4*points]
  270.      sub   dx,cx
  271.      sal   dx,1
  272.      sal   dx,1
  273.      mov   [ds:di+2*points],dx  
  274.  
  275.      mov   ax,[ds:xw]       
  276.      call  sinus
  277.      imul  [word ds:si+2*points]
  278.      mov   cx,dx
  279.      mov   ax,[ds:xw] 
  280.      call  cosinus
  281.      imul  [word ds:si+4*points]
  282.      add   dx,cx
  283.      sal   dx,1
  284.      sal   dx,1
  285.      mov   [ds:di+4*points],dx                
  286.      
  287.      pop   cx
  288.      add si,2
  289.      add di,2
  290.      dec cx
  291.      jnz rotz_it
  292.      ret
  293.  
  294. endp  rotate_z
  295.  
  296. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  297. ; DRAW-OBJECT / zeichnet das object bestehend aus den 2d-koordinaten
  298. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  299.  
  300. proc  draw_obj    NEAR
  301.      
  302.      mov dx,03c4h
  303.      mov ax,0102h
  304.      out dx,ax
  305.      
  306.      mov   si,offset lines
  307.      mov   cx,areas
  308.  
  309. Draw_Bonds:
  310.      
  311.      push  cx
  312.      xor   bh,bh
  313.      mov   bl,[ds:si]    
  314.      shl   bl,1
  315.      mov   ax,[ds:di+bx]        
  316.      mov   cx,[ds:di+2*points+bx] 
  317.      mov   [ds:x1],ax
  318.      mov   [ds:y1],cx
  319.      inc   si
  320.      mov   bl,[ds:si]
  321.      shl   bl,1
  322.      mov   ax,[ds:di+bx]        
  323.      mov   cx,[ds:di+2*points+bx]  
  324.      mov   [ds:x2],ax
  325.      mov   [ds:y2],cx
  326.      push  si
  327.      push  di
  328.      call  drawline
  329.      pop   di
  330.      pop   si
  331.      inc   si
  332.      pop   cx
  333.      dec cx
  334.      jnz  Draw_Bonds
  335.      ret
  336.  
  337. endp  draw_obj 
  338.  
  339. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  340. ; TRANSFORMATION-ROUTINE / rechnet die 3d-koord. in 2d koord. um
  341. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  342.  
  343. proc  transform     NEAR
  344.      
  345.          mov   cx,points
  346.          mov   di,offset _2dpoints
  347.          mov   si,offset _3dpoints
  348.  
  349. trans_it:mov   bx,[ds:si+4*points] 
  350.          sub   bx,[ds:dist]
  351.      
  352.          mov   ax,[ds:dist]
  353.          imul  [word ds:si]
  354.          idiv  bx            
  355.          sar   ax,1
  356.          sar   ax,1
  357.          sar   ax,1
  358.          sar   ax,1
  359.          add   ax,[ds:x_add]
  360.          mov   [ds:di],ax      
  361.      
  362.          mov   ax,[ds:dist]
  363.          imul  [word ds:si+2*points]
  364.          idiv  bx
  365.          sar   ax,1
  366.          sar   ax,1
  367.          sar   ax,1
  368.          sar   ax,1
  369.          add   ax,[ds:y_add]
  370.          mov   [ds:di+2*points],ax 
  371.      
  372.          add si,2
  373.          add di,2
  374.          dec cx
  375.          jnz trans_it
  376.          ret
  377.  
  378. endp  transform 
  379.  
  380. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  381. ; COSINUS-ROUTINE
  382. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  383.  
  384. proc  cosinus     NEAR
  385.  
  386.      add   ax,64
  387.  
  388.      push  bx
  389.      push  cx
  390.      push  si
  391.      
  392.      mov   bx,ax
  393.      shl   ax,1
  394.      and   ax,0ffh       
  395.      mov   si,offset sinustable
  396.      add   si,ax
  397.      mov   ax,[ds:si]     
  398.      clc
  399.      shl   bl,1         
  400.      jae   cos_pos
  401.      neg   ax            
  402. cos_pos:
  403.      pop   si
  404.      pop   cx
  405.      pop   bx
  406.      ret
  407.  
  408. endp  cosinus
  409.  
  410. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  411. ; SINUS-ROUTINE
  412. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  413.  
  414. proc  sinus    NEAR
  415.  
  416.      push  bx
  417.      push  cx
  418.      push  si
  419.      
  420.      mov   bx,ax
  421.      shl   ax,1
  422.      and   ax,0ffh       
  423.      mov   si,offset sinustable
  424.      add   si,ax
  425.      mov   ax,[ds:si]     
  426.      clc
  427.      shl   bl,1         
  428.      jae   sin_pos
  429.      neg   ax            
  430. sin_pos:
  431.      pop   si
  432.      pop   cx
  433.      pop   bx
  434.      ret
  435.  
  436. endp  sinus
  437.  
  438. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  439. ; DRAWLINE-ROUTINE / zieht eine linie von x1,y1 nach x2,y2 mit farbe col
  440. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  441.  
  442. proc  drawline   NEAR
  443.      
  444.      mov   ax,[ds:x1]
  445.      cmp   ax,[ds:x2]
  446.      jz    no_xadd
  447.      jmp   draw_it
  448.  
  449. no_xadd:
  450.      
  451.      mov   ax,[ds:y1]
  452.      cmp   ax,[ds:y2]
  453.      jnz   draw_it
  454.      
  455.      mov ax,[ds:x1]
  456.      mov bx,[ds:y1]
  457.      jmp   stop_line
  458.  
  459. draw_it:
  460.      
  461.      push  bp
  462.      mov   ax,[ds:x1]
  463.      mov   bx,[ds:y1]
  464.      push  ax
  465.      push  bx
  466.      mov   bx,4340h
  467.      mov   cx,[ds:x2]
  468.      sub   cx,ax
  469.      jge   deltax_1
  470.      mov   bl,48h
  471.      neg   cx
  472.  
  473. deltax_1:
  474.      
  475.      mov   dx,[ds:y2]
  476.      pop   si
  477.      push  si
  478.      sub   dx,si
  479.      jge   deltay_1
  480.      mov   bh,4bh
  481.      neg   dx
  482.  
  483. deltay_1:
  484.  
  485.      mov   si,offset line_add
  486.      mov   [word cs:si],bx
  487.      cmp   cx,dx
  488.      jge   deltax_2
  489.      mov   bl,90h
  490.      xchg  cx,dx
  491.      jmp   achse3
  492.  
  493. deltax_2:
  494.      
  495.      mov   bh,90h
  496.  
  497. achse3:
  498.      
  499.      mov   si,offset line_sub
  500.      mov   [word cs:si],bx
  501.      shl   dx,1
  502.      mov   bp,dx
  503.      sub   dx,cx
  504.      mov   di,dx
  505.      sub   dx,cx
  506.      pop   bx
  507.      pop   ax
  508.  
  509. line_loop:
  510.      
  511.      push  di
  512.      push  ax
  513.      push  dx
  514.      push  bx
  515.      push  cx
  516.      
  517.      push ax
  518.      mov ax,80
  519.      imul bx
  520.      pop cx
  521.      mov bx,cx
  522.      shr bx,1
  523.      shr bx,1
  524.      add ax,bx
  525.      mov si,ax
  526.  
  527.      and cl,3
  528.      mov ah,1
  529.      shl ah,cl
  530.      mov dx,03c4h
  531.      mov al,02h
  532.      out dx,ax
  533.  
  534.      mov al,[ds:color]
  535.      mov [es:si],al
  536.      
  537.  
  538.      
  539.      pop   cx
  540.      pop   bx
  541.      pop   dx
  542.      pop   ax
  543.      pop   di
  544.      cmp   di,0
  545.      jge   line_add
  546.  
  547. line_sub:
  548.      
  549.      inc   ax
  550.      inc   bx
  551.      add   di,bp
  552.      loop  line_loop
  553.      jmp   end_line
  554.  
  555. line_add:
  556.      
  557.      inc   ax
  558.      inc   bx
  559.      add   di,dx
  560.      loop  line_loop
  561.  
  562. end_line:
  563.      
  564.      pop     bp
  565.  
  566. stop_line:
  567.      
  568.      ret
  569.  
  570. endp  drawline 
  571.  
  572.  
  573.  
  574. proc  get_oldpos  NEAR
  575.  
  576.          mov cx,2*points
  577.  
  578.          mov si,offset _2dpoints
  579.          mov di,offset old2d
  580.  
  581. old_loop:mov ax,[ds:si]
  582.          mov [ds:di],ax
  583.          add si,2
  584.          add di,2
  585.          dec cx
  586.          jnz old_loop
  587.          
  588.          ret
  589.  
  590. endp  get_oldpos
  591.  
  592. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  593. ; FÜLLROUTINE V1.0
  594. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  595.  
  596. fill_obj  :  mov cx,frames
  597.              mov si,offset frame
  598.              mov di,offset _2dpoints
  599.  
  600. fill_obj1:   mov bl,[ds:si]
  601.              xor bh,bh
  602.              shl bx,1
  603.  
  604.              mov ax,[ds:di+bx] ;get 1st point of frame
  605.              mov [ds:t_x1],ax
  606.              mov ax,[ds:di+2*points+bx]
  607.              mov [ds:t_y1],ax
  608.  
  609.              inc si
  610.  
  611.              mov bl,[ds:si]
  612.              xor bh,bh
  613.              shl bx,1
  614.  
  615.              mov ax,[ds:di+bx]
  616.              mov [ds:t_x2],ax
  617.              mov ax,[ds:di+2*points+bx]
  618.              mov [ds:t_y2],ax
  619.  
  620.              inc si
  621.  
  622.              mov bl,[ds:si]
  623.              xor bh,bh
  624.              shl bx,1
  625.  
  626.              mov ax,[ds:di+bx]
  627.              mov [ds:t_x3],ax
  628.              mov ax,[ds:di+2*points+bx]
  629.              mov [ds:t_y3],ax
  630.  
  631.              inc si
  632.  
  633.              push cx
  634.              push si
  635.              push di
  636.  
  637.              call draw_polygon
  638.  
  639.              pop di
  640.              pop si
  641.              pop cx
  642.  
  643.              dec cx
  644.              jnz fill_obj1
  645.  
  646.              ret
  647.  
  648. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  649. ; SET 320*400 Graphics-mode (based on 4 bitplane-splitting) 
  650. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  651.  
  652. proc  set320400  NEAR
  653.  
  654.               mov ax,0013h      
  655.               int 10h
  656.  
  657.               mov dx,03c4h
  658.               mov al,04h
  659.               out dx,al
  660.               inc dx
  661.               in al,dx
  662.               and al,11110111b
  663.               out dx,al
  664.               dec dx
  665.               
  666.               mov ax,0f02h
  667.               out dx,ax
  668.  
  669.               mov dx,03d4h
  670.               mov al,14h
  671.               out dx,al
  672.               inc dx
  673.               in al,dx
  674.               and al,10111111b
  675.               out dx,al
  676.               dec dx
  677.               mov al,17h
  678.               out dx,al
  679.               inc dx
  680.               in al,dx
  681.               or al,01000000b
  682.               out dx,al
  683.  
  684.               mov dx,03d4h
  685.               mov al,09h
  686.               out dx,al
  687.               inc dx
  688.               in al,dx
  689.               and al,01110000b
  690.               out dx,al
  691.               
  692.               mov dx,03c4h
  693.               mov ax,0f02h
  694.               out dx,ax
  695.  
  696.               mov ax,0a000h
  697.               mov es,ax
  698.               assume es:0a000h
  699.               
  700.               mov cx,64000      ; alle bitplanes auf beiden grafikseiten
  701.               xor di,di         ; löschen...
  702.               xor eax,eax
  703.               cld
  704.               rep stosd
  705.  
  706.               ret
  707.  
  708. endp  set320400
  709.  
  710. proc  set640400  NEAR
  711.  
  712.               mov ax,000eh
  713.               int 10h
  714.  
  715.               mov dx,03d4h
  716.               mov al,09h
  717.               out dx,al
  718.               inc dx
  719.               in al,dx
  720.               and al,01111111b
  721.               out dx,al
  722.  
  723.               ret
  724.  
  725. endp  set640400
  726.  
  727. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  728. ; DRAWS A FILLED POLYGON WITH 3 POINTS 
  729. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  730.  
  731. draw_polygon:   mov ax,[ds:t_y1]
  732.                 cmp ax,[ds:t_y2]
  733.                 jbe s_ok_1
  734.  
  735.                 xchg ax,[ds:t_y2]
  736.                 mov [ds:t_y1],ax
  737.                 mov ax,[ds:t_x1]
  738.                 xchg ax,[ds:t_x2]
  739.                 mov [ds:t_x1],ax
  740.  
  741. s_ok_1:         mov ax,[ds:t_y2]
  742.                 cmp ax,[ds:t_y3]
  743.                 jbe s_ok_3
  744.                 
  745.                 xchg ax,[ds:t_y3]
  746.                 mov [ds:t_y2],ax
  747.                 mov ax,[ds:t_x3]
  748.                 xchg ax,[ds:t_x2]
  749.                 mov [ds:t_x3],ax
  750.  
  751. s_ok_2:         mov ax,[ds:t_y1]
  752.                 cmp ax,[ds:t_y2]
  753.                 jbe s_ok_3
  754.                 
  755.                 xchg ax,[ds:t_y2]
  756.                 mov [ds:t_y1],ax
  757.                 mov ax,[ds:t_x1]
  758.                 xchg ax,[ds:t_x2]
  759.                 mov [ds:t_x1],ax
  760.  
  761. s_ok_3:         mov bp,[ds:t_y3]
  762.                 mov dx,[ds:t_x3]
  763.                 mov ax,[ds:t_y1]
  764.                 mov bx,[ds:t_x1]
  765.                 mov di,offset buffer
  766.  
  767.                 call calc_line
  768.  
  769.                 mov bp,[ds:t_y2]
  770.                 mov dx,[ds:t_x2]
  771.                 mov ax,[ds:t_y1]
  772.                 mov bx,[ds:t_x1]
  773.                 mov di,offset buffer+2
  774.                 
  775.                 call calc_line
  776.  
  777.                 mov bp,[ds:t_y3]
  778.                 mov dx,[ds:t_x3]
  779.                 mov ax,[ds:t_y2]
  780.                 mov bx,[ds:t_x2]
  781.                 
  782.                 call calc_line
  783.  
  784.                 mov bx,01h
  785.                 
  786.                 mov bp,[ds:t_y3]
  787.                 sub bp,[ds:t_y1]
  788.                 inc bp
  789.  
  790.                 mov si,offset buffer
  791.  
  792.                 mov al,bl
  793.  
  794.                 imul dx,[ds:t_y1],ssizex/4
  795.  
  796. draw_nline:     mov di,[si]
  797.                 mov bx,[si+2]
  798.                 sub bx,di
  799.                 jnc width_pos
  800.  
  801.                 add di,bx
  802.                 neg bx
  803.  
  804. width_pos:      inc bx
  805.  
  806.                 push ax
  807.                 push dx
  808.                 call draw_line
  809.                 pop dx
  810.                 pop ax
  811.  
  812.                 add si,4
  813.                 add dx,ssizex/4
  814.                 dec bp
  815.                 jnz draw_nline
  816.  
  817. end_fill:       ret
  818.  
  819.  
  820.  
  821. calc_line:      xor cx,cx
  822.  
  823.                 sub bp,ax
  824.                 inc bp
  825.  
  826.                 sub dx,bx
  827.                 jnc dx_not_neg
  828.  
  829.                 mov cx,2
  830.                 neg dx
  831.  
  832. dx_not_neg:     inc dx
  833.                 mov ax,bx       ; Start address into ax
  834.  
  835.                 mov bx,1        ; assume x major
  836.                 sub bx,cx       ; see if going backwards
  837.                 mov cx,bp
  838.  
  839.                 cmp dx,bp       ; x major or y major?
  840.                 jbe x_major
  841.  
  842.                 mov cx,dx       ; else y major
  843.                 xchg bp,dx
  844.  
  845.                 mov si,bp
  846.  
  847. y_next_pixel:   sub si,dx       ; Dump = Dump - dy
  848.                 jnc y_positive
  849.  
  850.                 add si,bp       ; Dump = Dump + dx
  851.  
  852.                 mov [ds:di],ax
  853.                 add di,4
  854.  
  855. y_positive:     add ax,bx ; Add increment
  856.                 dec cx
  857.                 jnz y_next_pixel
  858.  
  859.                 sub ax,bx
  860.                 mov [ds:di],ax
  861.                 add di,4
  862.  
  863.                 jmp end_filled_triangle
  864.  
  865. x_major:        mov si,bp
  866.  
  867. x_next_pixel:   mov [ds:di],ax
  868.                 add di,4
  869.  
  870.                 sub si,dx ; Dump = Dump - dy
  871.                 jnc x_positive
  872.  
  873.                 add ax,bx ; Add increment
  874.                 add si,bp ; Dump = Dump + dx
  875.  
  876. x_positive:     dec cx
  877.                 jnz x_next_pixel
  878.  
  879. end_filled_triangle:    ret
  880.  
  881.  
  882.  
  883. draw_line:      mov cx,di
  884.                 shr di,2
  885.                 add di,dx
  886.  
  887.                 and cx,3
  888.                 add bx,cx
  889.                                                 
  890.                 mov ch,al
  891.                 mov ax,0f02h
  892.                 shl ah,cl
  893.                 mov dx,03c4h
  894.                 sub bx,4
  895.                 jg not_same_nibble
  896.  
  897.                 neg bl
  898.                 mov cl,bl
  899.                 mov bh,0fh
  900.                 shr bh,cl
  901.                 and ah,bh
  902.                 out dx,ax
  903.                 
  904.                 mov [es:di],ch
  905.                 ret
  906.  
  907.  
  908. not_same_nibble:out dx,ax
  909.                 mov [es:di],ch
  910.                 inc di
  911.  
  912.                 cmp bx,3
  913.                 jle skip_rep
  914.                 
  915.                 mov ax,0f02h
  916.                 out dx,ax
  917.                 mov al,ch
  918.                 mov cx,bx
  919.                 shr cx,2
  920.  
  921.                 rep stosb
  922.  
  923.                 mov ch,al
  924. skip_rep:       and bx,3
  925.                 jz no_last_byte
  926.  
  927.                 mov cl,bl
  928.                 mov ax,0f002h
  929.                 rol ah,cl
  930.                 out dx,ax
  931.  
  932.                 mov [es:di],ch
  933.  
  934. no_last_byte:   ret
  935.  
  936.  
  937. ends  coding
  938.  
  939. segment  data1
  940.  
  941.  
  942. ssizex                                  equ 320
  943. ssizey                                  equ 327
  944.  
  945. t_x1                    dw 0
  946. t_y1                    dw 0
  947. t_x2                    dw 0
  948. t_y2                    dw 0
  949. t_x3                    dw 0
  950. t_y3                    dw 0
  951.  
  952. buffer                  dw 1000 dup(0)
  953.  
  954. ;
  955. ; OBJEKT DATEN
  956. ;
  957.  
  958. xpos     dw 500,-500,-500
  959.          dw 200,-200,-200
  960.  
  961. ypos     dw 500,500,-500
  962.          dw 200,200,-200
  963.  
  964. zpos     dw 1000,1000,1000
  965.          dw 500,500,500
  966.  
  967.  
  968. ;
  969. ; BINDUNGSLISTE FÜR DIE OBJEKT-PUNKTE
  970. ;
  971.  
  972. lines db 0,1        
  973.       db 1,2
  974.       db 0,2
  975.  
  976.       db 3,4
  977.       db 4,5
  978.       db 3,5
  979.  
  980.  
  981. ; FLÄCHENLISTE FÜR FÜLLROUTINE
  982. ;
  983.  
  984. frame db 0,1,2
  985.       db 3,4,5
  986.  
  987.  
  988. ;
  989. ; DISTANZ VOM AUGE DES BETRACHTERS IN DEN 3D-RAUM
  990. ;
  991.  
  992. dist  dw 2000
  993.  
  994. ;
  995. ; SINUSTABELLE MIT 128 WERTEN
  996. ;
  997.  
  998. sinustable dw 0000h,0192h,0324h,04b5h,0646h
  999.            dw 07d6h,0964h,0af1h,0c7ch,0e06h,0f8dh
  1000.            dw 1112h,1294h,1413h,1590h,1709h,187eh
  1001.            dw 19efh,1b5dh,1cc6h,1e2bh,1f8ch,20e7h
  1002.            dw 223dh,238eh,24dah,2620h,2760h,289ah
  1003.            dw 29ceh,2afbh,2c21h,2d41h,2e5ah,2f6ch
  1004.            dw 3076h,3179h,3274h,3368h,3453h,3537h
  1005.            dw 3612h,36e5h,37b0h,3871h,392bh,39dbh
  1006.            dw 3a82h,3b21h,3bb6h,3c42h,3cc5h,3d3fh
  1007.            dw 3dafh,3e15h,3e72h,3ec5h,3f0fh,3f4fh
  1008.            dw 3f85h,3fb1h,3fd4h,3fech,3ffbh,4000h
  1009.            dw 3ffbh,3fech,3fd4h,3fb1h,3f85h,3f4fh
  1010.            dw 3f0fh,3ec5h,3e72h,3e15h,3dafh,3d3fh
  1011.            dw 3cc5h,3c42h,3bb6h,3b21h,3a82h,39dbh
  1012.            dw 392bh,3871h,37b0h,36e5h,3612h,3537h
  1013.            dw 3453h,3368h,3274h,3179h,3076h,2f6ch
  1014.            dw 2e5ah,2d41h,2c21h,2afbh,29ceh,289ah
  1015.            dw 2760h,2620h,24dah,238eh,223dh,20e7h
  1016.            dw 1f8ch,1e2bh,1cc6h,1b5dh,19efh,187eh
  1017.            dw 1709h,1590h,1413h,1294h,1112h,0f8dh
  1018.            dw 0e06h,0c7ch,0af1h,0964h,07d6h,0646h
  1019.            dw 04b5h,0324h,0192h
  1020.   
  1021. ;
  1022. ; LINIEN-PUNKTE FÜR draw_obj-ROUTINE
  1023. ;
  1024.  
  1025. x1      dw 0
  1026. x2      dw 0
  1027. y1      dw 0
  1028. y2      dw 0
  1029.  
  1030. ;
  1031. ; ECK-PUNKTE FÜR fill_frame-ROUTINE
  1032. ;
  1033.  
  1034. xf1     dw 0
  1035. xf2     dw 0
  1036. yf1     dw 0
  1037. yf2     dw 0
  1038.  
  1039. ;
  1040. ; WINKEL FÜR DIE DREHUNGEN IN X,Y UND Z-RICHTUNG
  1041. ;
  1042.  
  1043. xw      dw 0     
  1044. yw      dw 0
  1045. zw      dw 0
  1046.  
  1047. ;
  1048. ; PUNKTE FÜR FÜLLROUTINE
  1049. ;
  1050.  
  1051. f_x1    dw 0
  1052. f_y1    dw 0
  1053. f_x2    dw 0
  1054. f_y2    dw 0
  1055. f_x3    dw 0
  1056. f_y3    dw 0
  1057.  
  1058. ;
  1059. ; PUFFER FÜR ROTIERTE 3D-KOORDINATEN
  1060. ;
  1061.  
  1062. _3dpoints    dw 3*points DUP (1) ; gedrehte Koord.
  1063.  
  1064. ;
  1065. ; PUFFER FÜR UMGERECHNETE 2D-KOORDINATEN
  1066. ;
  1067.  
  1068. _2dpoints   dw 2*points DUP (1) ; 2D-Koordinaten
  1069.      
  1070. ;
  1071. ; PUFFER FÜR ALTE 2D-KOORDINATEN
  1072. ;
  1073.  
  1074. old2d       dw 2*points dup (0) ; Alte 2D-Koordinaten
  1075.  
  1076. ;
  1077. ; PUFFER FÜR FÜLLKOORDINATEN
  1078. ;
  1079.  
  1080. buffer_pos    dw 0
  1081. buffer_count  dw 0
  1082.  
  1083. fill_buf      dw 1000 dup (?)
  1084.  
  1085.  
  1086. ;
  1087. ; 2D-POINTER FÜR POSITIONIERUNG AUF BILDSCHIRM
  1088. ;
  1089.  
  1090. x_add    dw 160
  1091. y_add    dw 100
  1092.  
  1093. color    db 1
  1094.  
  1095. ends  data1
  1096.  
  1097. end start
  1098.